<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* 
*/
class MemberMenu extends MY_Controller
{
	
	public function __construct()
	{
		parent::__construct();
		
		$this->load->model('Main/MenuModel','menu');
	}


	//列表
	public function index()
	{
		$this->load->view('menu_list');
	}



	//获取数据
	public function get_list()
	{
		$res = $this->menu->get_list_data();

		if ($res) 
		{
			$data['list'] = $res;
			$data['status'] = 200;
			$data['message'] = '获取成功！';
		}
		else
		{
			$data['status'] = 400;
			$data['message'] = '数据获取失败！';
		}

		echo json_encode($data);exit();
	}


	//编辑
	public function edit_menu()
	{
		$data['menu_id'] = intval($this->uri->segment(3));

		if ($data['menu_id'] > 0) {
			$res = $this->menu->get_menu_row($data['menu_id']);
		}

		$data['title'] = isset($res['title']) ? $res['title'] : '';
		$data['theme_img'] = isset($res['theme_img']) ? $res['theme_img'] : '';

		//图片上传地址
		$data['image_upload_url'] = $this->image_load_url;

		$this->load->view('menu_info', $data);
	}


	//更新存库
	public function updata_menu()
	{

		$menu_id = $this->input->post('menu_id', TRUE);
		$arr['title'] = $this->input->post('title', TRUE);
		$arr['theme_img'] = $this->input->post('theme_img', TRUE);

		$res = $this->menu->updata_data($arr,$menu_id);

		if ($res) 
		{
			$data['status'] = 200;
			$data['message'] = '更新成功！';
		}
		else
		{
			$data['status'] = 400;
			$data['message'] = '更新失败！';
		}

		echo json_encode($data);exit();
	}




}






?>